package com.topvision.repository;

import com.topvision.domain.Device;
import com.topvision.dto.DeviceDTO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface DeviceRepository extends JpaRepository<Device, Long> {

    List<Device> findByCreatedBy(String name);

    @Query(value = "SELECT\n" +
            "\tdevice.*,device_info.remote_assistance_no,\n" +
            "\tdevice_info.remote_assitance_pwd,\n" +
            "\tdevice_info.resolution_lt\n" +
            "FROM\n" +
            "\tdevice\n" +
            "LEFT JOIN device_info ON device.bt_mac = device_info.bt_mac\n" +
            "WHERE\n" +
            "\tdevice.created_by = ?1", nativeQuery = true)
    List<Device> findByUserName(String name);

    Device findByBtMac(String btmac);

}
